<?php

namespace app\common\validate;

use think\Validate;

class Staff extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */	
	protected $rule = [
	    'ins_id' =>'require',
        'name'=>'require|max:10',
        'phone'=>'require|mobile',
        //'password'=>'^[a-zA-Z0-9_-!@]{4,16}$',
        'password'=>'require|alphaDash|length:6,16',
        'duties'=>'require|max:10',
        'authority'=>'require|in:1,2',

    ];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */
    protected $message = [
        'ins_id.require'=>'参数错误',
        'name.require'=>'请输入姓名',
        'name.max'=>'姓名过长',
        'phone.require'=>'请输入手机号',
        'phone.mobile'=>'您输入的手机号不正确',
        'password.require'=>'请输入密码',
        'password.alphaDash'=>'密码只能包含数字字母_-',
        'password.length'=>'密码长度只能在6到16位',
        'duties.require'=>'请输入职务',
        'duties.max'=>'职务名称过长',
        'authority.require'=>'请选择权限',
        'authority.in'=>'参数错误',
    ];

    protected $scene = [
        'add'  =>  ['ins_id','name','phone','password','duties','authority'],
        'edit' =>  ['name','phone','duties','authority']
    ];
}
